Typever
Table of Content
Type variables allow you to link several types together.
from typing import TypeVar
T = TypeVar("T")
def foo(arg: T) -> T:
return arg
TypeVar#
from typing import TypeVar
T = TypeVar("T")
def foo(arg: T) -> T:
return arg
import decimal
from typing import TypeVar
Number = TypeVar("Number", int, float, decimal.Decimal)
def double(value: Number) -> Number:
return value * 2
result: int
result = double(5)